//
//  SchoolViewController.m
//  Yu01
//
//  Created by 蒋松涵 on 16/8/19.
//  Copyright © 2016年 蒋松涵. All rights reserved.
//

#import "SchoolViewController.h"
#import "schoolTimetableViewController.h"
#import "ChengJiViewController.h"
#import "XuanKeViewController.h"
#import "MyLeaveVC.h"
#import "ClassroomInquireVC.h"

@interface SchoolViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView * tableView;

@end

@implementation SchoolViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];
    
    //导航栏字体颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    //修改导航栏添加的按钮（item）颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    
    [self tableview];
}

#pragma mark - tableView
-(void)tableview
{
    self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
}
#pragma mark - TableView的代理协议
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 5;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 1;
    }
    else if (section == 1)
    {
        return 1;
    }
    else if (section == 2)
    {
        return 1;
    }
    else if (section == 3)
    {
        return 1;
    }
    else
    {
        return 1;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//    CGFloat h = 736 / ScreenHeight;
    CGFloat w = 414 / ScreenWidth;
    
    static NSString * CellIdentifier = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
        //右边箭头
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        //取消选中效果
        cell.selectionStyle = UITableViewCellAccessoryNone;
    
    if (indexPath.section == 0)
    {
        //课表
        
        UIImageView * images = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 30, 30)];
        images.image = [UIImage imageNamed:@"其他小图标-01.png"];
        [cell.contentView addSubview:images];
        
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(50, 6, 80, 30)];
        label.text = @"课表";
        [cell.contentView addSubview:label];
        
        cell.detailTextLabel.text = @"更多";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:17/w];

    }
    else if (indexPath.section == 1)
    {
        //教室
        
        UIImageView * images = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 30, 30)];
        images.image = [UIImage imageNamed:@"其他小图标-02.png"];
        [cell.contentView addSubview:images];
        
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(50, 6, 80, 30)];
        label.text = @"教室";
        [cell.contentView addSubview:label];
        
        cell.detailTextLabel.text = @"查看";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:17/w];
    }
    else if (indexPath.section == 2)
    {
        //请假
        UIImageView * images = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 30, 30)];
        images.image = [UIImage imageNamed:@"其他小图标-03.png"];
        [cell.contentView addSubview:images];
        
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(50, 6, 80, 30)];
        label.text = @"请假";
        [cell.contentView addSubview:label];
        
        cell.detailTextLabel.text = @"申请";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:17/w];
    }
    else if (indexPath.section == 3)
    {
        //成绩
        
        UIImageView * images = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 30, 30)];
        images.image = [UIImage imageNamed:@"其他小图标-04.png"];
        [cell.contentView addSubview:images];
        
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(50, 6, 80, 30)];
        label.text = @"成绩";
        [cell.contentView addSubview:label];
        
        cell.detailTextLabel.text = @"查看";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:17/w];
    }
    else
    {
        //选课
        UIImageView * images = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 30, 30)];
        images.image = [UIImage imageNamed:@"其他小图标-05.png"];
        [cell.contentView addSubview:images];
        
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(50, 6, 80, 30)];
        label.text = @"选课";
        [cell.contentView addSubview:label];
        
        cell.detailTextLabel.text = @"更多";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:17/w];
    }
    return cell;
}
#pragma mark - 区的高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        
        return 2;
    }
    else if (section == 1)
    {
        
        return 2;
    }
    else if (section == 2)
    {
        return 2;
    }
    else if (section == 3)
    {
        
        return 2;
    }
    else
    {
        
        return 2;
    }

}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.section)
    {
        case 0:
        {
            //课表
            self.hidesBottomBarWhenPushed = YES;
            schoolTimetableViewController * schoolTimeVC = [[schoolTimetableViewController alloc]init];
            [self.navigationController pushViewController:schoolTimeVC animated:YES];
            self.hidesBottomBarWhenPushed = NO;
        }
            break;
        case 1:
        {
            //教室
            self.hidesBottomBarWhenPushed = YES;
            ClassroomInquireVC * classroomVC = [[ClassroomInquireVC alloc]init];
            [self.navigationController pushViewController:classroomVC animated:YES];
            self.hidesBottomBarWhenPushed = NO;
        }
            break;
        case 2:
        {
            //请假
            self.hidesBottomBarWhenPushed = YES;
            MyLeaveVC * MyVC = [[MyLeaveVC alloc]init];
            [self.navigationController pushViewController:MyVC animated:YES];
            self.hidesBottomBarWhenPushed = NO;
        }
            break;
        case 3:
        {
            //成绩
            self.hidesBottomBarWhenPushed = YES;
            ChengJiViewController * ChengJiVC = [[ChengJiViewController alloc]init];
            [self.navigationController pushViewController:ChengJiVC animated:YES];
            self.hidesBottomBarWhenPushed = NO;
        }
            break;
        case 4:
        {
            //选课
            self.hidesBottomBarWhenPushed = YES;
            XuanKeViewController * xuankeVC = [[XuanKeViewController alloc]init];
            [self.navigationController pushViewController:xuankeVC animated:YES];
            self.hidesBottomBarWhenPushed = NO;
        }
            break;
        default:
            break;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
